package com.baseframe.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baseframe.sys.entity.FrameAttachinfo;
import com.baseframe.sys.service.IFrameAttachinfoService;
import com.baseframe.sys.service.dao.FrameAttachinfoRepository;
import com.baseframe.sys.service.dao.FrameAttachstorageRepository;

/**
 * @author chenjia ghoulbfo@gmail.com
 * @date 2018/4/10 11:17
 */
@Service("frameAttachinfo")
public class FrameAttachinfoServiceImpl implements IFrameAttachinfoService {

	@Autowired
	private FrameAttachinfoRepository frameAttachinfoRepository;
	
	@Autowired
	private  FrameAttachstorageRepository  frameAttachstorageRepository;

	@Override
	public void save(FrameAttachinfo info) {
		frameAttachinfoRepository.save(info);
	}

	@Override
	public List<FrameAttachinfo> findByClientguid(String clientguid) {
		return frameAttachinfoRepository.findByClientguid(clientguid);
	}

	@Override
	public FrameAttachinfo selectById(String id) {
		return frameAttachinfoRepository.findOne(id);
	}

	@Override
	public int deleteAttach(FrameAttachinfo info) {
		frameAttachinfoRepository.delete(info.getAttachguid());
		frameAttachstorageRepository.delete(info.getAttachstorageguid());
		
		return 1;

	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public int deleteByClientguid(String clientguid) {
		int i = frameAttachinfoRepository.deleteByClientguid(clientguid);
		i = frameAttachstorageRepository.deleteByClientguid(clientguid);
		return i;
	}

}
